<!-- 任务执行情况 -->
<template>
  <el-dialog title="摇号参与人" :visible.sync="dialogVisible" @close="$emit('update:visible',false)"
             :close-on-click-modal="false">
    <div>
<!--      <div class="search-list-table">-->
<!--        <download :type="ranking"></download>-->
<!--      </div>-->
      <el-table
          ref="multipleTable"
          :data="arryList"
          tooltip-effect="dark"
          header-cell-class-name="table-text-c"
          height="400"
          cell-class-name="table-text-c">
        <el-table-column
            label="姓名"
            align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.realname">{{scope.row.realname}}</span>
            <span v-else>{{scope.row.name}}</span>
          </template>
        </el-table-column>
      </el-table>
      <!--工具条 分页-->
      <el-col :span="24" class="toolbar">
        <el-pagination
            background
            :page-size="page.pagesize"
            :current-page="page.pageindex"
            layout="total, prev, pager, next"
            :total="page.total"
            @current-change="handleSizeChange"></el-pagination>
      </el-col>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button @click="$emit('update:visible',false)" size="small">取 消</el-button>
<!--      <el-button type="primary" @click="foodCheck()" size="small">确 定</el-button>-->
    </div>
  </el-dialog>
</template>
<script>
import {pagination} from '@/utils/util.js'
import download from '@/components/common/download'

export default {
  name: 'taskListDialog',
  props: ['visible', 'id'],
  components: {
    download
  },
  data () {
    return {
      dialogVisible: this.visible,
      arryList: [],
      page: {
        pageindex: pagination.pageIndex,
        pagesize: pagination.pageSize,
        total: pagination.total
      },
      ranking: 'giftUser'
    }
  },
  watch: {
    visible () {
      this.dialogVisible = this.visible
      if (this.visible) {
        this.InitFn()
      } else {
        this.page.pageindex = 1
      }
    }
  },
  created () {
  },
  methods: {
    InitFn () {
      this.$fetch(this.api.giftDraw.participant, {id: this.id,p:this.page.pageindex}).then((response) => {
        for(let i in response.list.data){
          response.list.data[i].code = Number(response.list.data[i].code) < 10 ? ('0' + Number(response.list.data[i].code)) + '号' : response.list.data[i].code + '号'
        }
        this.arryList = response.list.data
        this.page.total = response.list.total
      }).catch((err) => {
        console.log(err)
      })
    },
    foodCheck () {

    },
    handleSizeChange (val) {
      this.page.pageindex = val
      this.InitFn()
    },
    // 搜索
    search () {
      this.page.pageindex = 1
      if (Number(this.rankingType) === 2) {
        this.fromDatauser.start_time = this.addtime ? this.addtime[0] : ''
        this.fromDatauser.end_time = this.addtime ? this.addtime[1] : ''
      } else {
        this.fromDatabook.start_time = this.addtime ? this.addtime[0] : ''
        this.fromDatabook.end_time = this.addtime ? this.addtime[1] : ''
      }
      this.InitFn()
    }
  },
  mounted () {

  }
}
</script>
